#include "objectpool.h"
class treenode
{
private:
	int val;
	treenode* _left;
	treenode* _right;
public:
	treenode():
		_left(nullptr),
		_right(nullptr),
		val(0)
	{}
};
int main()
{
	std::vector<treenode*> v1;
	std::vector<treenode*> v2;
	const int n =1000000;
	const int round = 10;
	objectpool <treenode> obj;
	size_t begin1 = clock();
	for (int i = 0; i < round; i++)
	{
		for (int j = 0; j < n; j++)
			v1.push_back(new(treenode));
		for (int j = 0; j < n; j++)
			delete(v1[i * n + j]);
	}
	size_t end1 = clock();
	size_t begin2 = clock();
	for (int i = 0; i < round; i++)
	{
		for (int j = 0; j < n; j++)
			v2.push_back(obj.New());
		for (int j = 0; j < n; j++)
			obj.Delete(v2[i * n + j]);
	}
	size_t end2 = clock();
	cout << "new:" << end1 - begin1 << endl;
	cout << "obj.new:" << end2 - begin2 << endl;
	return 0;
}